﻿using SuddenDeath.Domain.Services.FileManager.elFinder.Responses;
using SuddenDeath.Domain.Services.FileManager.elFinder.Utils;

namespace SuddenDeath.Domain.Services.FileManager.elFinder.Commands
{
    public class Open : ICommand
    {
        public string Target { get; set; }

        public Open(string target)
        {
            Target = target;
        }

        #region ICommand Members       

        public Response Execute()
        {
            var path = DirectoryUtils.GetRelativePathByHash(Target, Configuration.Configuration.RootPath);

            var folder = new Folder(path);

            var response = new DirectoryResponse { cwd = folder.Cwd, cdc = folder.Contents };

            return response;
        }

        #endregion
    }
}
